package com.wlz.behavioral.strategy.actual;

import com.wlz.behavioral.strategy.actual.strategy.ExecutorRouteFirst;
import com.wlz.behavioral.strategy.actual.strategy.ExecutorRouteLast;
import com.wlz.behavioral.strategy.actual.strategy.ExecutorRouteRandom;

/**
 * Created by xuxueli on 17/3/10.
 */
public enum ExecutorRouteStrategyEnum {

    FIRST("first", new ExecutorRouteFirst()),
    LAST("last", new ExecutorRouteLast()),
    RANDOM("random", new ExecutorRouteRandom());

    ExecutorRouteStrategyEnum(String title, ExecutorRouter router) {
        this.title = title;
        this.router = router;
    }

    private String title;
    private ExecutorRouter router;

    public String getTitle() {
        return title;
    }

    public ExecutorRouter getRouter() {
        return router;
    }

    public static ExecutorRouteStrategyEnum match(String name) {
        for (ExecutorRouteStrategyEnum item : ExecutorRouteStrategyEnum.values()) {
            if (item.name().equals(name)) {
                return item;
            }
        }
        return null;
    }

}
